package org.vectrics.recruiter.job.event;

import java.util.Locale;

import org.vectrics.common.html.BorderTable;
import org.vectrics.common.html.Cell;
import org.vectrics.domain.Domain;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.recruiter.email.RecruitEmailHtmlDefault;
import org.vectrics.recruiter.job.Job;
import org.vectrics.recruiter.job.JobCandidate;

public class JobCandidateHtmlEmail extends RecruitEmailHtmlDefault {
	private JobCandidate jobCandidate = null;
	private int tableWidth = 600;
	
	public JobCandidateHtmlEmail(Domain domain, Locale locale, JobCandidate jobCandidate) {
		super(domain, locale);
		this.jobCandidate = jobCandidate;
	}

	protected void renderContent(Cell cell) {
		cell.addElement("<font style=\"font:normal 0.8em Verdana\">"
				+ this.getPhrase("phrase.email.job.changed") + "</font><br>");
		this.addJobCandidateInfoTable(this.jobCandidate, cell);

		cell.addElement("<br><br><font style=\"font:normal 0.8em Verdana\">"
				+ this.getPhrase("phrase.job.candidate.status.history") + "</font><br><br>");
		cell.addElement(new JobCandidateStatusHistoryEmailTable(this.getLocale(), this.jobCandidate));
		
		
		cell.addElement("<br><br><font style=\"font:normal 0.8em Verdana\">"
				+ this.getPhrase("phrase.job.information") + "</font><br><br>");
		cell.addElement(new JobInfoEmailTable(this.getLocale(), this.jobCandidate.getJob()));
	}

	
	public void addJobCandidateInfoTable(JobCandidate jobCandidate, Cell mainCell) {
		mainCell.addElement("<br><br><font style=\"font:normal 0.8em Verdana\">"
				+ this.getPhrase("phrase.job.candidate.information") + "</font><br><br>");

		
		BorderTable table = new JobCandidateInfoEmailTable(this.getLocale(), jobCandidate, false);
		table.setWidth(tableWidth);
		mainCell.addElement(table);
	
	}
	
}
